package org.opens.excel.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @ExcelTarget注解属性说明:
 * - height: 定义行高
 * - value: 定义id
 * - fontSize: 设置字体大小
 */
@Data
@ExcelTarget("courseEntity")
public class CourseEntity implements Serializable {

    /**
     * 主键
     */
    private String id;

    /**
     * 课程名称
     * 说明:
     * - orderNum: 控制导出列的顺序
     * - needMerge: 在一对多情况下控制导出结果空行是否合并
     */
    @Excel(name = "课程名称", orderNum = "1", width = 25, needMerge = true)
    private String name;

    /**
     * 老师主键
     * @ExcelEntity注解属性说明:
     * - 当该注解的id属性为major时, 根据name = "主讲老师_major,代课老师_absent"的配置, 则header设置为主讲老师
     * - 当该注解的id属性为absent时, 根据name = "主讲老师_major,代课老师_absent"的配置, 则header设置为代课老师
     * - 当该注解的id属性为absent1时, 导出结果中将不出现这个字段
     */
    @ExcelEntity(id = "major")
    private TeacherEntity mathTeacher;


    /**
     * 属性说明:
     * - name: 控制表头
     * - type: 导入时创建对象使用
     */
    @ExcelCollection(name = "学生", orderNum = "4")
    private List<StudentEntity> students;

}
